<!--
 * @Author: your name
 * @Date: 2020-09-29 09:30:23
 * @LastEditTime: 2020-11-10 16:49:30
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \longh_admin\src\views\infoVerify\CooperationContent\CooperationContent.vue
-->
<template>
  <page-header-wrapper>
    <a-card :bordered="false" style="margin-bottom: 10px">
      <a-row type="flex" justify="space-between">
        <a-col>
          <span class="info">{{enttitle}}</span>
        </a-col>
        <a-col>
          <a-button @click="back">返回</a-button>
        </a-col>
      </a-row>
    </a-card>
    <a-card :bordered="false" title="招商信息审核">
      <a-row>
        <ul>
          <li class="list-info">
            <div class="item_lable">标题:</div>
            <div class="item_containt">

              {{InfoDetails.title}}
            </div>
          </li>
          <li class="list-info">
            <div class="item_lable">来源:</div>
            <div class="item_containt">

              {{InfoDetails.source}}
            </div>

          </li>
          <li class="list-info">
            <div class="item_lable">摘要:</div>
            <div class="item_containt">

              {{InfoDetails.merchantsAbstract}}
            </div>
          </li>
          <li class="list-info">
            <div class="item_lable">内容:</div>
            <div class="item_containt" v-html="InfoDetails.merchantsContent">
            </div>
          </li>
          <li class="list-info" v-if="InfoDetails.auditStatus !=1">
            <div class="item_lable">审核备注:</div>
            <div class="item_containt">
              {{InfoDetails.auditRemark}}
            </div>
          </li>
        </ul>
        <a-row type="flex">
          <p class="bottom" style="width:70px">附件：</p>
          <div v-for="(item,index) in InfoDetails.merchantsFile" :key="index">
            <a class="mr-10" :href="item.fileUrl"  target="_blank" download="">{{item.fileName}}</a>
          </div>
        </a-row>
      </a-row>
     
      <div v-if="InfoDetails.auditStatus == 1" style="margin-left: 40%;margin-top: 30px" >
        <a-button type="primary" class="mr-50" @click="success">通过</a-button>
        <a-button type="danger" class="mr-50" @click="showModal">不通过</a-button>
      </div>
      <a-modal v-model="visible" layout="vertical" title="审核退回" cancelText="取消" okText="提交" @ok="handleOk" :width="600">
        <a-form-model :model="form" ref="form" :rules="rules">
          <a-form-model-item label="审核不通过原因:" prop="desc">
            <a-textarea v-model="form.desc" :auto-size="{ minRows: 7, maxRows: 50 }" />
          </a-form-model-item>
        </a-form-model>
      </a-modal>
    </a-card>
  </page-header-wrapper>
</template>
<script>
import { entMerchantscheck, entMerchantsinfo } from '@/api/Merchants'
export default {
  data() {
    return {
      id: '',
      enttitle: '',
      type: false,
      visible: false,
      labelCol: { span: 6 },
      wrapperCol: { span: 15 },
      form: {
        desc: '',
      },
      rules: {
        desc: [
          {
            required: true,
            message: '请输入审核不通过原因',
            trigger: 'blur',
          },
        ],
      },
      InfoDetails: {},
    }
  },
  methods: {
    back() {
      this.$router.push('/infoVerify/CooperationContent/list')
    },
    showModal() {
      this.visible = true
    },
    onSubmit() {
      let that = this
      this.$refs.form.validate((valid) => {
        if (valid) {
          that.entMerchantscheck()
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    handleOk() {
      let that = this
      that.onSubmit()
      // this.visible = false
      // this.$message.success('审核处理完成！')
    },
    // 获取详情
    entMerchantsinfo() {
      entMerchantsinfo(this.id)
        .then((res) => {
          this.InfoDetails = res.data
        })
        .catch((error) => {})
    },
    // 审核未通过
    entMerchantscheck() {
      let _params = {
        auditStatus: 2,
        objectId: this.$route.query.id,
        type: 4,
        remark: this.form.desc,
      }
      let that =this;
      entMerchantscheck(_params)
        .then((res) => {
          if (res.code == 200) {
            that.visible = false
            that.$message.success('审核处理完成！')
               setTimeout(() => {
                  that.$router.push('/infoVerify/CooperationContent/list')
                }, 50)
            that.entMerchantsinfo()
          } else {
            that.$message.error(res.msg)
          }
        })
        .catch((error) => {})
    },
    // 审核成功
    success() {
      let that = this
      that.$confirm({
        title: '是否审核通过?',
        okText: '确定',
        okType: 'danger',
        cancelText: '取消',
        onOk() {
          console.log('OK')
          let _params = {
            auditStatus: 1,
            objectId: that.$route.query.id,
            type: 4,
          }
          entMerchantscheck(_params)
            .then((res) => {
              if (res.code == 200) {
                that.$message.success('审核通过！')
                setTimeout(() => {
                  that.$router.push('/infoVerify/CooperationContent/list')
                }, 50)
                that.entMerchantsinfo()
              } else {
                that.$message.error(res.msg)
              }
            })
            .catch((error) => {})
        },
        onCancel() {
          console.log('Cancel')
        },
      })
    },
  },
  created() {
    if (this.$route.query.id) {
      this.id = this.$route.query.id
      this.entMerchantsinfo()
    }
    if (this.$route.query.enttitle) {
      this.enttitle = this.$route.query.enttitle
    }
    if (this.$route.query.type) {
      if (this.$route.query.type == 'true') {
        this.type = true
      } else {
        this.type = false
      }
    }
  },
  mounted() {
    // console.log(this.$router.params)
  },
}
</script>
<style lang="less" scoped>
.info {
  font-family: 'Arial Negreta', 'Arial';
  font-weight: 700;
  font-style: normal;
  font-size: 24px;
  color: #333333;
}
.list-info {
  border-bottom: 1px dashed #ebeef5;
  line-height: 24px;
  padding: 10px 0;
  color: #030303;
  display: flex;
  .item_lable {
    width: 60px;
    color: #909399;
  }
  .item_containt {
    margin-left: 10px;
    color: #030303;
    p {
      margin: 0 !important;
      margin-bottom: 0em !important;
    }
  }
}
.down_file {
  cursor: pointer;
  color: #1890ff;
}
</style>